<template>
    <div id='mapDom' style="width: 100%;height: 100%;">

    </div>
</template>

<script setup>
import { onMounted } from 'vue'
import * as echarts from 'echarts'
import '../../../common/china'
import { dealWithData } from '../../../utils/cityPostion'
let dataValue = dealWithData();
// let data1 = dataValue.splice(1, 8);
// let data2 = dataValue.splice(10, 30);
// let data3 = dataValue.splice(30, 60);

const props = defineProps({
    data: Object
})


onMounted(() => {
    let initMap = echarts.init(document.querySelector('#mapDom'))
    let data1 = props.data[0].data
    let data2 = props.data[1].data
    let data3 = props.data[2].data
    initMap.setOption(
        {
            backgroundColor: 'transparent', // 设置背景色透明
            tooltip: {
                // show: true
            },
            geo: {
                map: "china",
                roam: false,// 一定要关闭拖拽
                zoom: 1.23,
                center: [105, 36], // 调整地图位置
                regions: [
                    {
                        name: "南海诸岛",
                        selected: false,
                        emphasis: {
                            disabled: false,
                        },
                        itemStyle: {
                            // 隐藏地图
                            normal: {
                                opacity: 0, // 为 0 时不绘制该图形
                            }
                        },
                        label: {
                            show: false // 隐藏文字
                        }
                    }
                ],
                label: {
                    normal: {
                        show: false, //关闭省份名展示
                        fontSize: "10",
                        color: "rgba(0,0,0,0.7)"
                    },
                    emphasis: {
                        show: false
                    }
                },
                itemStyle: {

                    normal: {
                        // areaColor: "#090c15",
                        // borderColor: "#4996cc",
                        // borderWidth: 5, //设置外层边框
                        // shadowBlur: 5,
                        // shadowOffsetY: 8,
                        // shadowOffsetX: 0,
                        // shadowColor: "#01012a",
                        // opacity: 0,

                        areaColor: 'rgba(0,255,255,.02)',
                        borderColor: '#4996cc',
                        borderWidth: 5,
                        shadowColor: 'transparent',
                        // shadowOffsetX: 0,
                        // shadowOffsetY: 4,
                        shadowBlur: 10,

                    },
                    emphasis: {
                        areaColor: "#184cff",
                        shadowOffsetX: 0,
                        shadowOffsetY: 0,
                        shadowBlur: 5,
                        borderWidth: 2,
                        shadowColor: "rgba(0, 0, 0, 0.5)",
                    }
                }
            },
            series: [
                {
                    select: {
                        disabled: true,
                    },
                    type: "map",
                    map: "china",
                    roam: false,
                    zoom: 1.23,
                    center: [105, 36],
                    // geoIndex: 1,
                    // aspectScale: 0.75, //长宽比
                    showLegendSymbol: false, // 存在legend时显示
                    label: {
                        normal: {
                            show: false
                        },
                        emphasis: {
                            show: false
                        }
                    },
                    itemStyle: {
                        normal: {
                            // transparent
                            areaColor: "#090c15",
                            borderColor: "#4996cc",
                            borderWidth: 1,
                            opacity: 1
                        },
                        emphasis: {
                            areaColor: '#4996cd',
                            shadowOffsetX: 0,
                            shadowOffsetY: 0,
                            shadowBlur: 5,
                            borderWidth: 0,
                            shadowColor: "rgba(0, 0, 0, 0.5)"
                        }
                    }
                },
                {
                    name: "",
                    type: "effectScatter",
                    coordinateSystem: "geo",
                    data: data1,
                    symbol: "circle",
                    zlevel: 2,
                    rippleEffect: {
                        brushType: 'stroke'
                    },
                    symbolSize: 8,
                    hoverSymbolSize: 10,
                    animation: true,
                    tooltip: {
                        formatter(value) {
                            return value.data.name + "<br/>" + `${props.data[0].title}`;
                        },
                        show: true
                    },
                    encode: {
                        value: 2
                    },
                    label: {
                        formatter: "{b}",
                        position: "right",
                        show: false
                    },
                    itemStyle: {
                        color: "#77fc52",
                    },
                    emphasis: {
                        label: {
                            show: false,
                        }
                    }
                }, {
                    name: "",
                    type: "effectScatter",
                    coordinateSystem: "geo",
                    data: data3,
                    symbol: "circle",
                    zlevel: 2,
                    rippleEffect: {
                        brushType: 'stroke'
                    },
                    symbolSize: 8,
                    hoverSymbolSize: 10,
                    tooltip: {
                        formatter(value) {
                            return value.data.name + "<br/>" + `${props.data[2].title}`;
                        },
                        show: true
                    },
                    encode: {
                        value: 2
                    },
                    label: {
                        formatter: "{b}",
                        position: "right",
                        show: false
                    },
                    itemStyle: {
                        color: "#e76932"
                    },
                    emphasis: {
                        label: {
                            show: false
                        }
                    }
                }, {
                    name: "",
                    type: "effectScatter",
                    coordinateSystem: "geo",
                    data: data2,
                    symbol: "circle",
                    symbolSize: 8,
                    hoverSymbolSize: 10,
                    zlevel: 2,
                    rippleEffect: {
                        brushType: 'stroke'
                    },
                    tooltip: {
                        formatter(value) {
                            return value.data.name + "<br/>" + `${props.data[1].title}`;
                        },
                        show: true
                    },
                    encode: {
                        value: 2
                    },
                    label: {
                        formatter: "{b}",
                        position: "right",
                        show: false
                    },
                    itemStyle: {
                        color: "#e9fb5a"
                    },
                    emphasis: {
                        label: {
                            show: false
                        }
                    }
                }

            ]
        }
    )

})
</script>

<style scoped lang="scss">
#mapDom {
    display: flex;
    align-items: center;
}
</style>